package edu.cmu.cs.stage3.alice.authoringtool.viewcontroller;

import edu.cmu.cs.stage3.alice.authoringtool.AuthoringToolResources;

/**
 * @author Jason Pratt
 */
public class PropertyLabel extends javax.swing.JLabel {
	protected edu.cmu.cs.stage3.alice.core.Property property;

	public PropertyLabel( edu.cmu.cs.stage3.alice.core.Property property ) {
		this.property = property;
		setOpaque( false );
		property.addPropertyListener(
				new edu.cmu.cs.stage3.alice.core.event.PropertyListener() {
					public void propertyChanging( edu.cmu.cs.stage3.alice.core.event.PropertyEvent propertyEvent ) {}
					public void propertyChanged( edu.cmu.cs.stage3.alice.core.event.PropertyEvent propertyEvent ) {
						PropertyLabel.this.update();
					}
				}
		);
		update();
	}

	public void update() {
		setText( AuthoringToolResources.getReprForValue( property.get(), property ) );
	}
}
